﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using EnvDTE;
using System.Text.RegularExpressions;

namespace VSIXUtilities.Helpers
{
	internal static class ConvertEx
	{
		public static IVsHierarchy ToIVsHierarchy(Project project)
		{
			IVsSolution solution = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution;
			IVsHierarchy hierarchy;
			solution.GetProjectOfUniqueName(project.FullName, out hierarchy);
			return hierarchy;
		}

        public static string[] GetFriendlyNames<TEnum>() where TEnum : struct
		{
			List<string> Result = new List<string>();
			foreach(string stringItem in Enum.GetNames(typeof(TEnum)))
			{
				Result.Add(Regex.Replace(stringItem, @"(?<LowerCase>[\p{Ll}])(?<UpperCase>[\p{Lu}])", "${LowerCase} ${UpperCase}"));
			}
			return Result.ToArray();
		}
	}
}
